﻿//https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/submissions/607530186/?envType=problem-list-v2&envId=dynamic-programming&difficulty=EASY

class Solution {
public:
    int maxProfit(vector<int>& prices)
    {
        int ret = 0;
        int minprices = prices[0];
        for (auto& e : prices)
        {
            ret = max(ret, e - minprices);

            minprices = min(minprices, e);
        }
        return ret;
    }
};